//
//  HMNewFeatureController.swift
//  HMWeibo12
//
//  Created by iOS on 16/9/19.
//  Copyright © 2016年 iOS. All rights reserved.
//

import UIKit

private let reuseIdentifier = "Cell"

/// 新特性界面
class HMNewFeatureController: UICollectionViewController {
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    let layout = UICollectionViewFlowLayout()
    
    init() {
        super.init(collectionViewLayout: layout)
    }

    override func viewDidLoad() {
        super.viewDidLoad()
        // Register cell classes
        self.collectionView!.register(HMNewFeatureCell.self, forCellWithReuseIdentifier: reuseIdentifier)
        
        setupLayout()
    }
    
    /// 设置布局
    private func setupLayout() {
        layout.itemSize = self.view.bounds.size
        layout.minimumLineSpacing = 0
        layout.minimumInteritemSpacing = 0
        layout.scrollDirection = UICollectionViewScrollDirection.horizontal
        
        collectionView?.bounces = false
        collectionView?.isPagingEnabled = true
        collectionView?.showsHorizontalScrollIndicator = false
    }

    override func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
        return NewFeatureCount
    }

    override func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
        let cell = collectionView.dequeueReusableCell(withReuseIdentifier: reuseIdentifier, for: indexPath) as! HMNewFeatureCell
    
        // 设置cell的indexPath
        cell.indexPath = indexPath
        
        return cell
    }

}
